package Opgave1;



public class Node {
	Node left;
	Node right;
	int value;
	boolean isVisited;
	
	public Node(int val) {
		this.value = val;
		//System.out.println(value);
	}
	
	public Node getLeft() {
		return left;
	}
	
	public Node getRight() {
		return right;
	}

	public int getValue(){
		return value;
	}
	
	public void setVisited(boolean newBoolean){
		isVisited = newBoolean;
	}
	
	public boolean getVisited(){
		return isVisited;
	}

	public void addChild(int newNode) {
		if (newNode <= value) {
			if (left == null)
				left = new Node(newNode);
			else
				left.addChild(newNode);
		}
		else if (newNode > value) {
			if (right == null)
				right = new Node(newNode);
			else 
				right.addChild(newNode);
		}	
		else{
			addChild(newNode);
		}
	}	
}
